package com.itheima.conllection;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;

public class CollectionDemo03 {
    public static void main(String[] args) {
        LinkedList<String> list=new LinkedList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        list.addFirst("dddd");
        System.out.println("--------------------------");
        Iterator<String> it=list.listIterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("---------------------------");
     list.addLast("www");
        System.out.println(list);
        System.out.println("---------------------------");
//        System.out.println(list.removeFirst());
//        System.out.println(list);
//        System.out.println(list.removeLast());
//        System.out.println(list);
//        System.out.println(list.getFirst());
//        System.out.println(list.getLast());
        for (String s:list){
            System.out.print(s+" ");
        }
    }
}
